var PauseLayer = cc.Layer.extend({
	_lastScale:0,
	ctor:function (targets) {
		this._super();

		target = targets;
		var deadLayer = ccs.load(res.Pause_json).node;

		this.addChild(deadLayer, 1);
//
		back = deadLayer.getChildByName("back");
		goon = deadLayer.getChildByName("goon");
		restart = deadLayer.getChildByName("repeat");
		
//		classicModeBtn = new ccui.Button("res/Button_ClassicModel.png");
//		classicModeBtn.x = 540;
//		classicModeBtn.y = 1127.23;
//		this.addChild(classicModeBtn);
//		classicModeBtn.addClickEventListener(this.restartClicked.bind(this));

		back.addClickEventListener(this.backClicked.bind(this));
		goon.addClickEventListener(this.goonClicked.bind(this));
		restart.addClickEventListener(this.restartClicked.bind(this));

	},
	restartClicked: function(sender) {
		if(music)
			cc.audioEngine.playEffect(res.buttonClickEffect, false);
		cc.log("remove begin");
//		cc.eventManager.removeAllListeners();
		target.space.removeCollisionHandler(BALL_COLLISION_TYPE, BALL_COLLISION_TYPE);
		target.space.removeCollisionHandler(BALL_COLLISION_TYPE, BOTTOM_WALL_COLLISION_TYPE);
		target.space.removeCollisionHandler(BALL_COLLISION_TYPE, TOP_THREE_WALL_COLLISION_TYPE);
		target.space.removeCollisionHandler(BALL_COLLISION_TYPE, BAR_COLLISION_TYPE);
		cc.log("remove over");
		if(curGameMode == PROP_MODE)
			cc.director.replaceScene(new cc.TransitionSlideInB(0.5, new PropModeScene()));
		else
			cc.director.replaceScene(new cc.TransitionSlideInB(0.5, new ClassicModeScene()));
	},
	backClicked: function(sender) {
		if(music)
			cc.audioEngine.playEffect(res.buttonClickEffect, false);
		cc.log("remove begin");
		target.space.removeCollisionHandler(BALL_COLLISION_TYPE, BALL_COLLISION_TYPE);
		target.space.removeCollisionHandler(BALL_COLLISION_TYPE, BOTTOM_WALL_COLLISION_TYPE);
		target.space.removeCollisionHandler(BALL_COLLISION_TYPE, TOP_THREE_WALL_COLLISION_TYPE);
		target.space.removeCollisionHandler(BALL_COLLISION_TYPE, BAR_COLLISION_TYPE);
//		cc.eventManager.removeAllListeners();
		cc.log("remove over");
		cc.director.runScene(new cc.TransitionSlideInR(0.5, new StartScene()));
	},
	goonClicked: function(sender){
		if(music)
			cc.audioEngine.playEffect(res.buttonClickEffect, false);
		
		paused = false;
		
		this.removeFromParent(true);
	}
});